package saxparsertest;

import java.util.ArrayList;
import java.util.List;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class VulnerabilityHandler extends DefaultHandler {
    
    private List<Vulnerability> vulList = null;
    private Vulnerability vul = null;

    public List<Vulnerability> getVulList() {
        return vulList;
    }
    
    boolean bTitle;
    boolean bDescription;
    boolean bPublished;

    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
        super.endElement(uri, localName, qName); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        if (qName.equalsIgnoreCase("Vulnerability")) {
            String title = attributes.getValue("Title");
            vul = new Vulnerability();
            vul.setTitle(title);
            if (vulList == null) {
                vulList = new ArrayList<>();
            }
        }
    }

    @Override
    public void endDocument() throws SAXException {
        super.endDocument(); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void startDocument() throws SAXException {
        super.startDocument(); //To change body of generated methods, choose Tools | Templates.
    }
    
    
    
}
